import QtQuick 1.1

Item {
    width: 400
    height: 500
    id: rectangle1
    property int margin: 15
    property string feedType: "all"
    LeftTitle{
        id: titleAll
        y: 10
        width: 27
        height: 21
        underline: true
        size: 20
        text: "all"
        anchors.left: parent.left
        anchors.leftMargin: 10
        anchors.top: parent.top
        anchors.topMargin: margin
        MouseArea {
             anchors.fill: parent
             onClicked: {
                 feedType = "all"
                parent.underline = true
                 titleNews.underline = false
                 titleFacebook.underline = false
                 titleTwitter.underline = false
             }

        }
    }
    LeftTitle{
        id: titleNews
        x: 87
        y: 0
        width: 55
        height: 21

        size: 20
        text: "news"
        anchors.top: parent.top
        anchors.topMargin: margin
        MouseArea {
             anchors.fill: parent
             onClicked: {
                    feedType = "news"
                 titleAll.underline = false
                 titleNews.underline = true
                 titleFacebook.underline = false
                 titleTwitter.underline = false
             }

        }
    }
    LeftTitle{
        id: titleFacebook
        x: 191
        y: 0
        width: 96
        height: 21

        size: 20
        text: "facebook"
        anchors.top: parent.top
        anchors.topMargin: margin

        MouseArea {
             anchors.fill: parent
             onClicked: {
                 feedType = "facebook"
                 titleAll.underline = false
                 titleNews.underline = false
                 titleFacebook.underline = true
                 titleTwitter.underline = false
             }

        }
    }
    LeftTitle{
        id: titleTwitter
        x: 318
        y: 10
        width: 72
        height: 21

        size: 20
        text: "twitter"

        anchors.top: parent.top
        anchors.topMargin: margin

        MouseArea {
             anchors.fill: parent
             onClicked: {
                 feedType = "twitter"
                 titleAll.underline = false
                 titleNews.underline = false
                 titleFacebook.underline = false
                 titleTwitter.underline = true
             }

        }
    }





    XmlListModel {
        id: xmlFeeds
        source: "Assets/news/"+feedType+".xml"
        query: "/info/note"
        XmlRole { name: "type"; query: "type/string()" }
        XmlRole { name: "author"; query: "author/string()" }
        XmlRole { name: "author_image"; query: "author_image/string()" }
        XmlRole { name: "textS"; query: "text/string()" }
        XmlRole { name: "time"; query: "time/string()" }
    }



Component {
    id: xmlFeedsDelegate
    Rectangle {
        width:380
        height: 70
        color: "#206088"

        Image {
            id: image1
            x: 0
            y: 0
            width: 70
            height: 70
            source: author_image
        }

        Text {
            id: textAuthor
            x: 74
            y: 2
            text: author
            font.family: "Georgia"
            font.bold: true
            font.pixelSize: 11
        }
        Text {
            id: dtext
            x: 74
            y: 16
            anchors.top: textAuthor.bottom
            anchors.topMargin: 0
            width: 324
            height: 42
            color: "#ffffff"


            text: textS
            wrapMode: Text.WordWrap
            font.family: "Georgia"
            font.bold: false
            font.pixelSize: 10

            Text {
                id: text1
                x: 0
                y: 41
                color: "#aa9b9b"
                text: time
                font.pixelSize: 10
            }
        }

        Image {
            id: imgType
            x: 52
            y: 52
            width: 18
            height: 18
            source: "Assets/news/"+type+".png"
        }
    }
}

Item {
    id: rectangle2
    x: 0
    y: 55
    width: 400
    height: 370


    ListView {
        x: 9
        y: 7
        width: 380
        height: 363
        contentHeight: 400
        contentWidth: 400


        clip: true
                       boundsBehavior: Flickable.StopAtBounds
        spacing: 1
        model: xmlFeeds
        delegate: xmlFeedsDelegate

    }
}
}


//Michal
